# -*- coding:utf-8 -*-
from tkinter import*
from main import*


class FenetreJeu(Frame):
    "creation de la fenetre de jeu"
    def __init__(self,m):
    ## Construction de la fenètre de jeu##
        self.fen1=Tk()
        self.can=Canvas(self.fen1,width=700,height=600)
        self.grille=PhotoImage(file='imagedepatou.gif')
        self.grillejeu=self.can.create_image(350,300,image=self.grille)
        self.photoovalr=PhotoImage(file='Imagepiece_rouge.gif')
        self.photoovalb=PhotoImage(file='Imagepiece_bleue.gif')
        self.lbljoueur=Label(self.fen1,text="joueur 1")
        self.x,self.y=0,0
        self.can.pack()
        self.lbljoueur.pack()
        self.can.bind("<Button-1>",action)
        self.fen1.mainloop()
        
    def descente_piece(self,colone,deb,fin):
        #for i in range(0,len(self.mp)):
        #    if event.x in range(self.mp[i][0],self.mp[i][0]):
        #        self.x==mp[i][0]+(4)*i+45
        #        self.mx=i
        #défini le couleure de la pièce
        self.oval=self.can.create_image(colone,deb,image=self.photoovalr)
        self.grillejeu=self.can.create_image(350,300,image=self.grille)
        self.continu=True
        self.annim(deb,fin,20,colone)
        
    def colone_pleine(self):
        
        self.fen2=Tk()
        Label(self.fen2,text="la colonne est pleine").pack()
        self.fen2.after(1000,self.fen2.destroy)

    def display_player(self,strr_player):
        self.lbljoueur.configure(text=strr_player)
            
    def annim(self,deb,fin,pas,col):
        ##Fait l'annimation de la pièce##
        if deb<fin:
            deb+=pas
            self.can.coords(self.oval,col,deb)
            self.fen1.after(1,self.annim(deb,fin,pas,col))
            print("ok")


        
            
        
        
        
    
    
    
        
